package cn.wen.action;

import java.util.Map;


import cn.wen.util.JSONUtil;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport
{
	private static final long serialVersionUID = 1L;
	private String indentifyCode;

	@SuppressWarnings({ "null" })
	public void login()
	{
		if (indentifyCode == null && indentifyCode.equals(""))
		{
			System.out.println("值不能为空");
			return;
		}

		// 获取session中存储的code值
		Map<String, Object> session = ActionContext.getContext().getSession();
		String sessionCode = (String) session.get("code");

		if (sessionCode == null && sessionCode.equals(""))
		{
			System.out.println("值不能为空");
			return;
		}

		// 判断两个值是否相等
		if (indentifyCode.equals(sessionCode))
		{
			JSONUtil.writeText("true");
		} else
		{
			JSONUtil.writeText("false");
		}
	}

	public String getIndentifyCode()
	{
		return indentifyCode;
	}

	public void setIndentifyCode(String indentifyCode)
	{
		this.indentifyCode = indentifyCode;
	}
}
